<%--

<!------------------------------------------------------------------------------
 - Copyright 2006 CORE Solutions Limited
 - All rights reserved.
 - PROPRIETARY AND CONFIDENTIAL INFORMATION.
 - Use is subject to license terms.
 -
 - FUNCTION ID      :   ITEM_LINE
 - AUTHOR           :   Alex Cheung
 - DATE CREATE      :   2006/01/19
 - DESCRIPTION      :   a PAGE-EDIT CONTENT JSP file for the function, ITEM_LINE
 -                  :
 -                  :
 -                  :
 -
 - MODIFICATION HISTORY:
 - DATE         AUTHOR          VERSION NO.         COMMENT
 - -----------  --------------  ------------------  -------------------
 - 2006/01/19   Alex Cheung     1.0                 source is generated.
 -
 -
 -
------------------------------------------------------------------------------->

--%>
<%@ include file="/jsp/com/erp/app/common/jsp/directives_include.jsp"%>

<%@ page  import="com.erp.app.catalog.itemLine.web.ItemLineAction" %>
<%@ page  import="com.erp.app.catalog.itemLine.web.ItemLineRow" %>

<%@ include file="/jsp/com/erp/app/common/jsp/html_include.jsp"%>

<jsp:useBean id="itemLineForm" scope="session" type="com.erp.app.catalog.itemLine.web.ItemLineForm" />

<%
ArrayList itemLineList = itemLineForm.getMultiRows();
pageContext.setAttribute("itemLineList", itemLineList);
rowReadOnly = false;
TableSchema ts = itemLineForm.getTs();
%>

<script language="javascript">

	function doLoad() {
		<%
		if (CommonUtil.nullToString((String)session.getAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE)).equals(ProjectConstants.GENERIC_YES)) {
			session.removeAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE);
			out.println("alert('Records saved.');");
		}
		%>
	}

	function doEditItemLine(val) {
		document.forms[0].editItemLine.value = val;
		doSubmit('<%=ItemLineAction.ACTION_EDIT_ITEM_LINE%>');
	}


</script>

<body onLoad="javascript:doLoad();autofill_init();">
<html:form action="/itemLine">

<html:hidden property="pageEvent"/>
<html:hidden property="pageMode"/>

<html:hidden property="editItemLine"/>
<html:hidden property="pageEventSrc"/>
<table class="table_button">

<tr>
	<td>
		<chtml:button form="itemLineForm" pageEvent="<%=ItemLineAction.ACTION_EXIT%>"
			styleClass="button1"/>
		<chtml:button form="itemLineForm" pageEvent="<%=ItemLineAction.ACTION_SEARCH%>"
			styleClass="button1"/>
		<chtml:button form="itemLineForm" pageEvent="<%=ItemLineAction.ACTION_CLEAR%>"
			styleClass="button1"/>
		<chtml:button form="itemLineForm" pageEvent="<%=ItemLineAction.ACTION_ADD_ROW%>"
			styleClass="button1"/>
		<chtml:button form="itemLineForm" pageEvent="<%=ItemLineAction.ACTION_SAVE%>"
			styleClass="button1"/>
	</td>
</tr>

<tr>
	<td>

		<table class="table_crit">
        <tr class="col_label">
			<td class="col_label">&nbsp;</td>
			<td class="col_label_fr_to">
				<%
				webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_FROM");
				%>
				<%=webLabel%>
			</td>
			<td class="col_label_fr_to">
				<%
				webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_TO");
				%>
				<%=webLabel%>
			</td>
			
		</tr>

		<tr>
			<%
			webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_ITEM_LINE");
			%>
			<td class="col_label">
			<%=webLabel%>
			</td>
			<td class="col_value">
				<html:text property="srchItemLineFr" styleClass="textbox1" size="<%=srchDisplaySize%>" maxlength="<%=srchColSize%>"/>
			</td>
			<td class="col_value">
				<html:text property="srchItemLineTo" styleClass="textbox1" size="<%=srchDisplaySize%>" maxlength="<%=srchColSize%>"/>
			</td>

		</tr>
		<tr>
			<%
			webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_ITEM_LINE_DESC");
			%>
			<td class="col_label">
			<%=webLabel%>
			</td>
			<td class="col_value" colspan="2">
				<html:text property="srchItemLineDescFr" styleClass="textbox1" size="<%=srchDisplayLongSize%>" maxlength="<%=srchColLongSize%>"/>
			</td>

		</tr>
		</table>

	</td>
</tr>

<tr>
	<td><font color='red'><html:errors/></font></td>
</tr>

<tr>
	<td class="grid_page">
	<%if(itemLineForm.getTotalPage() == 0 ) { %>
		&nbsp;
	<%} else { %>
	    <input type="button" value="Go" class="button1" onClick="javascript:doSubmit('<%=itemLineForm.ACTION_SCROLL_TO%>');" >
		Page
		<html:text property="scrollTo" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="4" size="4" value="<%=String.valueOf(itemLineForm.getCurrentPage())%>"/>
	    of <%=itemLineForm.getTotalPage()%>
	<%} %>
	    <input type="button" value="|&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=ItemLineAction.ACTION_SCROLL_TO_FIRST_PAGE%>');" <%=itemLineForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=ItemLineAction.ACTION_SCROLL_LEFT%>');" <%=itemLineForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&gt;&gt;" class="button1" onClick="javascript:doSubmit('<%=ItemLineAction.ACTION_SCROLL_RIGHT%>');" <%=itemLineForm.getSidx() < Integer.parseInt(itemLineForm.getLastPageSidx()) ? "" : "disabled"%>>
	    <input type="button" value="&gt;&gt|" class="button1" onClick="javascript:doSubmit('<%=ItemLineAction.ACTION_SCROLL_TO_LAST_PAGE%>');" <%=itemLineForm.getSidx() < Integer.parseInt(itemLineForm.getLastPageSidx()) ? "" : "disabled"%>>
	</td>
</tr>

</table>


<table class="table_short_grid">

	<tr class="grid_header">
	    <td class="grid_header_col" nowrap>
			Del
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_ITEM_LINE");
		%>
		<td class="grid_header_col" nowrap>
			<span class="mandatory_label">
				<bean:message key="label.general.mandatory.field"/><%=webLabel%>
			</span>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_ITEM_LINE_DESC");
		%>
		<td class="grid_header_col" nowrap>
			<bean:message key="label.general.mandatory.field"/>
			<span class="mandatory_label"><%=webLabel%></span>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_STATUS");
		%>
		<td class="grid_header_col" nowrap>
			<span class="mandatory_label">
				<bean:message key="label.general.mandatory.field"/><%=webLabel%>
			</span>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_CATEGORY");
		%>
		<td class="grid_header_col" nowrap>
			<span class="mandatory_label">
				<bean:message key="label.general.mandatory.field"/><%=webLabel%>
			</span>
		</td>
		<td class="grid_header_col" nowrap>

        </td>
	</tr>

	<logic:iterate id="itemLineRow" name="itemLineList" indexId="idx" length="<%=String.valueOf(ProjectConstants.MAX_DISPLAY)%>" offset="<%=String.valueOf(itemLineForm.getSidx())%>">

	<%
		ItemLineRow row = (ItemLineRow) itemLineRow;
	%>

<% if((row != null) && (CommonUtil.isEmpty(row.getIsDelete()))) {%>

	<tr <%=(idx.intValue()%2 == 0)? "class='grid_result1'": "class='grid_result2'"%>>
		<td nowrap>
		<chtml:button form="itemLineForm" pageEvent="<%=ItemLineAction.ACTION_DELETE_ROW%>" pageEventSrc="<%=String.valueOf(idx)%>" styleClass="button1" disabled="<%=String.valueOf(rowReadOnly)%>"/>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(ts.getColSizeByObjectId("LBL_GRID_ITEM_LINE"));
			displaySize = String.valueOf(ts.getDisplaySizeByObjectId("LBL_GRID_ITEM_LINE"));
			%>
			<logic:equal name="itemLineRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				 
				<html:hidden property="itemLine" value="<%=CommonUtil.nullToString(row.getItemLine())%>"/> < To be generated. >
			</logic:equal>
			<logic:notEqual name="itemLineRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				<a href="javascript:doEditItemLine('<%=row.getItemLine()%>');" style="text-decoration: underline;">
					<bean:write name="itemLineRow" property="itemLine" filter="true"/>
				</a>
				<html:hidden property="itemLine" value="<%=CommonUtil.nullToString(row.getItemLine())%>"/>
			</logic:notEqual>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(ts.getColSizeByObjectId("LBL_GRID_ITEM_LINE_DESC"));
			displaySize = String.valueOf(ts.getDisplaySizeByObjectId("LBL_GRID_ITEM_LINE_DESC"));
			%>
			<html:text property="itemLineDesc" styleClass="textbox1" readonly="<%=rowReadOnly%>" size="<%=displaySize%>" maxlength="<%=colSize%>" value="<%=CommonUtil.nullToString(row.getItemLineDesc())%>"/>
		</td>
		<td nowrap>
			<select name="status" <%=rowReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
				<% where = "TYPE='" + ProjectConstants.CONSTANT_TYPE_ACT_INACT + "'";%>
				<chtml:options table="T_SYS_CONSTANTS"
					valuecolumn="CONSTANT_CODE"
					textcolumn="CONSTANT_NAME"
					where= "<%=where%>"
					order="ORDER_SEQ"
					selected="<%=row.getStatus()%>" />
			</select>
		</td>
		<td nowrap>
			<select name="browser" <%=rowReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
				<% where = "TYPE='" + ProjectConstants.CONSTANT_TYPE_YES_NO + "'";%>
				<chtml:options table="T_SYS_CONSTANTS"
					valuecolumn="CONSTANT_CODE"
					textcolumn="CONSTANT_NAME"
					where= "<%=where%>"
					order="ORDER_SEQ"
					selected="<%=row.getBrowser()%>" />
			</select>
		</td>	
		<td nowrap>			
		<%if(!ProjectConstants.ROW_MODE_CREATE.equals(row.getRowMode())){ %>	
          		<chtml:button form="itemLineForm" pageEvent="<%=ItemLineAction.ACTION_EDIT_ITEM_DETAIL_TEMPLATE%>" pageEventSrc="<%=String.valueOf(idx)%>" styleClass="button1" disabled="<%=String.valueOf(rowReadOnly)%>"/>
        <%}%>
        </td>
	</tr>

	<% } else{%>
	<html:hidden property="isDelete" value="<%=row.getIdx()%>"/>
	<html:hidden property="itemLineDesc" value="<%=row.getItemLineDesc()%>"/>
	<html:hidden property="status" value="<%=row.getStatus()%>"/>
	<html:hidden property="itemLine" value="<%=CommonUtil.nullToString(row.getItemLine())%>"/>
	<html:hidden property="browser" value="<%=CommonUtil.nullToString(row.getBrowser())%>"/>
	
	
	<% }
	// end if(row != null) %>

	<html:hidden property="idx" value="<%=row.getIdx()%>" />
	<html:hidden property="rowMode"  value="<%=row.getRowMode()%>"/>

	</logic:iterate>

</table>

</html:form>
